home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch1 / Mirror.frm < prev    next >
Text File  |  1999-03-18  |  7KB  |  224 lines

  1. VERSION 5.00
  2. Begin VB.Form MirrorForm 
  3.    AutoRedraw      =   -1  'True
  4.    Caption         =   "Mirror"
  5.    ClientHeight    =   3705
  6.    ClientLeft      =   3705
  7.    ClientTop       =   450
  8.    ClientWidth     =   3420
  9.    LinkTopic       =   "Form1"
  10.    PaletteMode     =   1  'UseZOrder
  11.    ScaleHeight     =   3705
  12.    ScaleWidth      =   3420
  13.    Begin VB.CommandButton cmdMirror 
  14.       Caption         =   "Mirror"
  15.       Default         =   -1  'True
  16.       Height          =   495
  17.       Left            =   1080
  18.       TabIndex        =   0
  19.       Top             =   120
  20.       Width           =   1215
  21.    End
  22.    Begin VB.PictureBox picPSetDest 
  23.       AutoRedraw      =   -1  'True
  24.       AutoSize        =   -1  'True
  25.       Height          =   1020
  26.       Left            =   0
  27.       ScaleHeight     =   64
  28.       ScaleMode       =   3  'Pixel
  29.       ScaleWidth      =   64
  30.       TabIndex        =   12
  31.       Top             =   2280
  32.       Width           =   1020
  33.    End
  34.    Begin VB.PictureBox picPaintDest 
  35.       AutoRedraw      =   -1  'True
  36.       AutoSize        =   -1  'True
  37.       Height          =   1020
  38.       Left            =   2400
  39.       ScaleHeight     =   64
  40.       ScaleMode       =   3  'Pixel
  41.       ScaleWidth      =   64
  42.       TabIndex        =   11
  43.       Top             =   2280
  44.       Width           =   1020
  45.    End
  46.    Begin VB.PictureBox picRefreshDest 
  47.       AutoRedraw      =   -1  'True
  48.       AutoSize        =   -1  'True
  49.       Height          =   1020
  50.       Left            =   1200
  51.       ScaleHeight     =   64
  52.       ScaleMode       =   3  'Pixel
  53.       ScaleWidth      =   64
  54.       TabIndex        =   10
  55.       Top             =   2280
  56.       Width           =   1020
  57.    End
  58.    Begin VB.PictureBox picRefreshSource 
  59.       AutoRedraw      =   -1  'True
  60.       AutoSize        =   -1  'True
  61.       Height          =   1020
  62.       Left            =   1200
  63.       Picture         =   "Mirror.frx":0000
  64.       ScaleHeight     =   64
  65.       ScaleMode       =   3  'Pixel
  66.       ScaleWidth      =   64
  67.       TabIndex        =   7
  68.       Top             =   1200
  69.       Width           =   1020
  70.    End
  71.    Begin VB.PictureBox picPaintSource 
  72.       AutoRedraw      =   -1  'True
  73.       AutoSize        =   -1  'True
  74.       Height          =   1020
  75.       Left            =   2400
  76.       Picture         =   "Mirror.frx":0882
  77.       ScaleHeight     =   64
  78.       ScaleMode       =   3  'Pixel
  79.       ScaleWidth      =   64
  80.       TabIndex        =   2
  81.       Top             =   1200
  82.       Width           =   1020
  83.    End
  84.    Begin VB.PictureBox picPSetSource 
  85.       AutoRedraw      =   -1  'True
  86.       AutoSize        =   -1  'True
  87.       Height          =   1020
  88.       Left            =   0
  89.       Picture         =   "Mirror.frx":1104
  90.       ScaleHeight     =   64
  91.       ScaleMode       =   3  'Pixel
  92.       ScaleWidth      =   64
  93.       TabIndex        =   1
  94.       Top             =   1200
  95.       Width           =   1020
  96.    End
  97.    Begin VB.Label Label1 
  98.       Alignment       =   2  'Center
  99.       Caption         =   "Point/PSet W/refresh"
  100.       Height          =   375
  101.       Index           =   2
  102.       Left            =   1200
  103.       TabIndex        =   9
  104.       Top             =   720
  105.       Width           =   1020
  106.    End
  107.    Begin VB.Label lblRefresh 
  108.       BorderStyle     =   1  'Fixed Single
  109.       Height          =   255
  110.       Left            =   1200
  111.       TabIndex        =   8
  112.       Top             =   3360
  113.       Width           =   1020
  114.    End
  115.    Begin VB.Label lblPaint 
  116.       BorderStyle     =   1  'Fixed Single
  117.       Height          =   255
  118.       Left            =   2400
  119.       TabIndex        =   6
  120.       Top             =   3360
  121.       Width           =   1020
  122.    End
  123.    Begin VB.Label lblPSet 
  124.       BorderStyle     =   1  'Fixed Single
  125.       Height          =   255
  126.       Left            =   0
  127.       TabIndex        =   5
  128.       Top             =   3360
  129.       Width           =   1020
  130.    End
  131.    Begin VB.Label Label1 
  132.       Alignment       =   2  'Center
  133.       Caption         =   "PaintPicture"
  134.       Height          =   255
  135.       Index           =   1
  136.       Left            =   2400
  137.       TabIndex        =   4
  138.       Top             =   840
  139.       Width           =   1020
  140.    End
  141.    Begin VB.Label Label1 
  142.       Alignment       =   2  'Center
  143.       Caption         =   "Point/PSet"
  144.       Height          =   255
  145.       Index           =   0
  146.       Left            =   0
  147.       TabIndex        =   3
  148.       Top             =   840
  149.       Width           =   1020
  150.    End
  151. End
  152. Attribute VB_Name = "MirrorForm"
  153. Attribute VB_GlobalNameSpace = False
  154. Attribute VB_Creatable = False
  155. Attribute VB_PredeclaredId = True
  156. Attribute VB_Exposed = False
  157. Option Explicit
  158.  
  159. ' Mirror the images.
  160. Private Sub cmdMirror_Click()
  161. Dim X As Single
  162. Dim Y As Single
  163. Dim wid As Single
  164. Dim hgt As Single
  165. Dim start_time As Single
  166. Dim stop_time As Single
  167.  
  168.     ' Prepare.
  169.     cmdMirror.Enabled = False
  170.     MousePointer = vbHourglass
  171.     DoEvents
  172.     
  173.     ' Clear any previous results.
  174.     picPSetDest.Line (0, 0)-(picPSetDest.ScaleWidth, picPSetDest.ScaleHeight), picPSetDest.BackColor, BF
  175.     picRefreshDest.Line (0, 0)-(picPSetDest.ScaleWidth, picPSetDest.ScaleHeight), picPSetDest.BackColor, BF
  176.     picPaintDest.Line (0, 0)-(picPSetDest.ScaleWidth, picPSetDest.ScaleHeight), picPSetDest.BackColor, BF
  177.     lblPSet.Caption = ""
  178.     lblRefresh.Caption = ""
  179.     lblPaint.Caption = ""
  180.     Refresh
  181.  
  182.     ' Mirror using PSet/Paint.
  183.     start_time = Timer
  184.     wid = picPSetSource.ScaleWidth
  185.     For X = 0 To wid
  186.         For Y = 0 To picPSetSource.ScaleHeight
  187.             picPSetDest.PSet (wid - X, Y), picPSetSource.Point(X, Y)
  188.         Next Y
  189.     Next X
  190.     stop_time = Timer
  191.     lblPSet.Caption = Format$(stop_time - start_time, "0.000") & " sec"
  192.     Refresh
  193.     
  194.     ' Mirror using PSet/Paint with refresh.
  195.     start_time = Timer
  196.     wid = picRefreshSource.ScaleWidth
  197.     For X = 0 To wid
  198.         For Y = 0 To picRefreshSource.ScaleHeight
  199.             picRefreshDest.PSet (wid - X, Y), picRefreshSource.Point(X, Y)
  200.         Next Y
  201.         picRefreshDest.Refresh
  202.     Next X
  203.     stop_time = Timer
  204.     lblRefresh.Caption = Format$(stop_time - start_time, "0.000") & " sec"
  205.     Refresh
  206.  
  207.     ' Mirror using PaintPicture.
  208.     start_time = Timer
  209.     wid = picPaintSource.ScaleWidth
  210.     hgt = picPaintSource.ScaleHeight
  211.     picPaintDest.PaintPicture picPaintSource.Picture, _
  212.         0, 0, wid + 1, hgt, _
  213.         wid + 1, 0, -(wid + 1), hgt, vbSrcCopy
  214.     stop_time = Timer
  215.     lblPaint.Caption = Format$(stop_time - start_time, "0.000") & " sec"
  216.  
  217.     MousePointer = vbDefault
  218.     cmdMirror.Enabled = True
  219. End Sub
  220. ' End if the program is in the middle of drawing.
  221. Private Sub Form_Unload(Cancel As Integer)
  222.     End
  223. End Sub
  224.